package cn.xabad.commons.sample.ui.commons;

import butterknife.ButterKnife;
import cn.xabad.commons.ui.OttoManager;

/**
 * Created by xuelei on 15/9/9.
 */
public abstract class BaseCourseFragment extends BaseFragment {

    public boolean isViewShown = false;

    public abstract void visibleToUser();

    public abstract void inVisibleToUser();

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if (isVisibleToUser) {
            isViewShown = true;
            visibleToUser();
        } else {
            isViewShown = false;
            inVisibleToUser();
        }
    }

    @Override
    public void onDestroyView() {
        ButterKnife.unbind(this);
        OttoManager.unregister(this);
        super.onDestroy();
    }
}
